{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
        margin-left: 3.333px;
    }

    .search {
        margin-bottom: 0px !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {eq name='type' value='1'}asdlkjasd{/eq}" href="{:url('index',['type'=>1])}">积分记录</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='2'}asdlkjasd{/eq}" href="{:url('index',['type'=>2])}">金币记录</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                             <!--    <div class="columns columns-right btn-group pull-left" >
                                    <select class="form-control" name="where">
                                        <option value="">全部</option>
                                        <option value="id">文章ID</option>
                                    </select>
                                </div> -->
                                <div class="columns columns-right btn-group pull-left" >
                                </div>
                                {php}
                                if(input('?param.search_typeid') || input('?param.search_name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('index')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" id="filter" type="text"
{php}
if(input('?param.search_name')){
            if(input('param.search_name')){
               echo "value='".input('search_name')."'";
            } 
        }
{/php}
                                     name="search_name" placeholder="输入标题搜索">
                                </div>


                            </div>
                            <div class="pull-right search" style="display: flex;">
                                <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                  <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">文件ID</th>
                                    <th data-align="center">管理</th>
                                    <th>文件标题</th>
                                    <th>文件格式</th>
                                    <th data-align="center">创建时间</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.file_id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.file_id}"></td>
                                    <td id="id">{$v.file_id}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onclick="down('{$v.file_id}')">立即下载</a></li>
                                                <li><a onclick="down('{$v.file_id}', 1)">下载链接</a></li>
                                                <!-- <li><a onclick="add('{:url('add',['id'=>$v.file_id,'url'=>-1])}')">文件详情</a></li> -->
                                                <li class="divider"></li>
                                                <li><a onclick="del({$v.file_id})">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td id="title">
                                        {$v.file_name}
                                    </td>
                                    <td>
                                        {$v.file_ext}
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d H:i:s')==$v['create_time'])echo 'style="color: #ed5565"';{/php}>{$v.create_time|date="Y-m-d H:i",###}</span>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>                          

                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
    $('#desAll').click(function(){
        var des=$(".form-horizontal").serialize();
        ajaxFun("post",'{:url('article/desAll')}',des,'json',function(ret){
            if(ret){
                if(ret.ret){
                    self.location.reload();
                }else{
                    layer.msg(ret.err)
                }
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    })
     
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })

    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })
});
function del(id){
    swal_del(id,"{:url('del')}")
}

function watch(id) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['100%', '100%'],
          type: 2,
          content: '{:url('article/watch')}?id='+id // //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
        });


    });
}

function down(id, url = 0) {
    ajaxFun("post",'{:url('down')}?id=' + id,'','json',function(ret){
        if(ret){
            if(ret.ret){
                if(url){
                    layer.open({
                      title :'下载链接',
                      area: ['500px', '150px'],
                      type: 1,
                      content: '<div style="word-break:break-all;padding:20px;">' + ret.ret + '</div>'
                    });
                }else{
                    window.open(ret.ret)
                }
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}
</script>
 